/**
 * Copyright(c) 2014 Xunton Solutions
 *
 * History:
 *   15-12-14 下午1:00 Created by dwzhang
 */
package com.jade.bss.ec.ware;

import java.io.Serializable;
import javax.persistence.*;

/**
 * 商品属性，根据商品分类来定。
 *
 * @author <a href="mailto:dwzhang@xunton.com">dwzhang</a> 
 * @version 1.0 15-12-14 下午1:00
 */
@Entity
@Table (name = "BSS_EC_WARE_ATTR")
public class WareAttribute
        implements Serializable
{
    public static final int TYPE_KEY = 1;
    public static final int TYPE_FIX = 2;
    public static final int TYPE_CHANGE = 3;
    public static final int TYPE_SALE = 4;
    //无效属性
    public static final int STATUS_INVALID = 0;
    //有效属性
    public static final int STATUS_VALID = 1;
    @Id
    @GeneratedValue (generator = "BSS_SEQ_EC_WARE_ATTR")
    @SequenceGenerator (name = "BSS_SEQ_EC_WARE_ATTR", sequenceName = "BSS_SEQ_EC_WARE_ATTR")
    //属性标识
    private long id;
    //商品分类
    @Column (name = "cid", nullable = false)
    private long cid;
    //商品标识，商品的自定义属性需要
    @Column (name = "ware_id")
    private long wareId;
    //属性分组,对属性进行分组管理
    @Column (name = "gid")
    private long gid;
    //属性名称
    @Column (name = "name", length = 64, nullable = false)
    private String name;
    //属性类型  1 - 关键属性  2 - 不变属性 3 - 可变属性 4 - 销售属性
    @Column (name = "type")
    private int type;
    //属性值的取值类型  1 - 单选值  2 - 多选值  3 - 输入值
    @Column (name = "value_type")
    private int valueType;
    //属性值的取值，valueType为1，2时，该项填写的是ConfigGroup的key，为其他值时为空
    @Column (name = "value")
    private String value;
    //是否必选属性
    @Column (name = "required")
    private boolean required;
    //是否过滤属性
    @Column (name = "filtered")
    private boolean filtered;
    //是否导航属性
    @Column (name = "navigator")
    private boolean navigator;
    //是否颜色属性，暂时不确定是否有用，京东有
    @Column (name = "color_attr")
    private boolean colorAttr;
    //是否尺码属性，暂时不确定是否有用，京东有
    @Column (name = "size_attr")
    private boolean sizeAttr;
    //排序码，越小越靠前
    @Column (name = "sort_code")
    private int sortCode;
    //状态
    @Column (name = "status")
    private int status = STATUS_VALID;

    public long getId()
    {
        return id;
    }

    public void setId(long id)
    {
        this.id = id;
    }

    public long getCid()
    {
        return cid;
    }

    public void setCid(long cid)
    {
        this.cid = cid;
    }

    public long getWareId()
    {
        return wareId;
    }

    public void setWareId(long wareId)
    {
        this.wareId = wareId;
    }

    public long getGid()
    {
        return gid;
    }

    public void setGid(long gid)
    {
        this.gid = gid;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public int getType()
    {
        return type;
    }

    public void setType(int type)
    {
        this.type = type;
    }

    public int getValueType()
    {
        return valueType;
    }

    public void setValueType(int valueType)
    {
        this.valueType = valueType;
    }

    public String getValue()
    {
        return value;
    }

    public void setValue(String value)
    {
        this.value = value;
    }

    public boolean isRequired()
    {
        return required;
    }

    public void setRequired(boolean required)
    {
        this.required = required;
    }

    public boolean isFiltered()
    {
        return filtered;
    }

    public void setFiltered(boolean filtered)
    {
        this.filtered = filtered;
    }

    public boolean isNavigator()
    {
        return navigator;
    }

    public void setNavigator(boolean navigator)
    {
        this.navigator = navigator;
    }

    public boolean isColorAttr()
    {
        return colorAttr;
    }

    public void setColorAttr(boolean colorAttr)
    {
        this.colorAttr = colorAttr;
    }

    public boolean isSizeAttr()
    {
        return sizeAttr;
    }

    public void setSizeAttr(boolean sizeAttr)
    {
        this.sizeAttr = sizeAttr;
    }

    public boolean isKeyAttr()
    {
        return type == TYPE_KEY;
    }

    public boolean isSaleAttr()
    {
        return type == TYPE_SALE;
    }

    public int getSortCode()
    {
        return sortCode;
    }

    public void setSortCode(int sortCode)
    {
        this.sortCode = sortCode;
    }

    public int getStatus()
    {
        return status;
    }

    public void setStatus(int status)
    {
        this.status = status;
    }
}
